﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TYLitedbBase;

namespace DSPara
{
    public class OffsetCreator: CreatorBase
    {
        /// <summary>
        /// 这个是配置的数据库
        /// </summary>
        /// <param name="_dbName"></param>
        public OffsetCreator(string dbName) : base(dbName)
        {
           
        }

        public bool InitOffset(OffsetPara offsetPara, ref string error)
        {
            var liteDBHelper = new LiteDB_BaseHelper<Entity_Offset>(dbName);
            if (liteDBHelper.Get(x => x.SectionId == offsetPara.Section, out Entity_Offset listData))
            {
                if (listData == null)
                {
                    error = "无默认配置补偿!!";
                    return false;
                }
                offsetPara.Init(listData);
                return true;
            }
            else
            {
                error = $" 读取补偿值 异常!section:{offsetPara.Section}-本地文件为{LiteDBHelper.GetFileFullPath(dbName)} ";
            }
            return false;
        }
    }
}